XendDomain.instance().get_vm_by_uuid(vm_ref).info[name])
def VM_set(self, name, session, vm_ref, value):
- XendDomain.instance().get_vm_by_uuid(vm_ref).info[name] = value
+ xd = XendDomain.instance()
+ dominfo = xd.get_vm_by_uuid(vm_ref)
+ dominfo.info[name] = value
+ xd.managed_config_save(dominfo)
return xen_api_success_void()
# attributes (ro)
"""
cfg = {}
- # First step is to convert deprecated options to
- # current equivalents.
+ for key, typ in XENAPI_CFG_TYPES.items():
+ val = sxp.child_value(sxp_cfg, key)
+ if val is not None:
+ cfg[key] = typ(val)
+
+ # Convert deprecated options to current equivalents.
restart = sxp.child_value(sxp_cfg, 'restart')
if restart:
"""
cfg = self._parse_sxp(sxp_cfg)
+ for key, typ in XENAPI_CFG_TYPES.items():
+ val = cfg.get(key)
+ if val is not None:
+ self[key] = typ(val)
+
# Convert parameters that can be directly mapped from
# the Legacy Config to Xen API Config
except KeyError:
pass
- self['PV_bootloader'] = cfg.get('bootloader', '')
- self['PV_bootloader_args'] = cfg.get('bootloader_args', '')
-
+ def update_with(n, o):
+ if not self.get(n):
+ self[n] = cfg.get(o, '')
+
+ update_with('PV_bootloader', 'bootloader')
+ update_with('PV_bootloader_args', 'bootloader_args')
+
image_sxp = sxp.child_value(sxp_cfg, 'image', [])
if image_sxp:
self.update_with_image_sxp(image_sxp)
self.validate()
- def to_xml(self):
- """Return an XML string representing the configuration."""
- pass
-
- def to_sxp(self, domain = None, ignore_devices = False, ignore = []):
+ def to_sxp(self, domain = None, ignore_devices = False, ignore = [],
+ legacy_only = True):
""" Get SXP representation of this config object.
Incompat: removed store_mfn, console_mfn
if domain.getDomid() is not None:
sxpr.append(['domid', domain.getDomid()])
+ if not legacy_only:
+ for name in XENAPI_CFG_TYPES.keys():
+ if name in self and self[name] not in (None, []):
+ sxpr.append([name, str(self[name])])
+
for xenapi, legacy in XENAPI_CFG_TO_LEGACY_CFG.items():
if self.has_key(xenapi) and self[xenapi] not in (None, []):
if type(self[xenapi]) == bool:
log.trace("XendDomainInfo.update done on domain %s: %s",
str(self.domid), self.info)
- def sxpr(self, ignore_store = False):
+ def sxpr(self, ignore_store = False, legacy_only = True):
result = self.info.to_sxp(domain = self,
- ignore_devices = ignore_store)
+ ignore_devices = ignore_store,
+ legacy_only = legacy_only)
if not ignore_store and self.dompath:
vnc_port = self.readDom('console/vnc-port')